package cn.webestar.scms.user.api.dto.Corp;

import cn.webestar.scms.commons.api.SimpleBody;
import cn.webestar.scms.user.entity.Corp;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.Date;

@Data
@Schema(description = "CorpSimpleDTO")
public class CorpSimpleDTO extends SimpleBody {

    @Schema(description = "名称")
    private String name;

    @Schema(description = "状态，1：正常")
    private Integer status;

    @Schema(description = "创建人")
    private Long creator;

    @Schema(description = "更新人")
    private Long updater;

    @Schema(description = "删除人")
    private Long deleter;

    @Schema(description = "创建时间")
    private Date createTime;

    @Schema(description = "更新时间")
    private Date updateTime;

    @Schema(description = "删除时间")
    private Date deleteTime;

    @Schema(description = "是否已删除")
    private Boolean isDeleted;

    @Override
    public LambdaQueryWrapper<Corp> toQueryWapper() {
        LambdaQueryWrapper<Corp> queryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.hasText(name)) {
            queryWrapper.eq(Corp::getName, name);
        }
        if (status!=null) {
            queryWrapper.eq(Corp::getStatus, status);
        }
        if (creator!=null) {
            queryWrapper.eq(Corp::getCreator, creator);
        }
        if (updater!=null) {
            queryWrapper.eq(Corp::getUpdater, updater);
        }
        if (deleter!=null) {
            queryWrapper.eq(Corp::getDeleter, deleter);
        }
        if (createTime!=null) {
            queryWrapper.eq(Corp::getCreateTime, createTime);
        }
        if (updateTime!=null) {
            queryWrapper.eq(Corp::getUpdateTime, updateTime);
        }
        if (deleteTime!=null) {
            queryWrapper.eq(Corp::getDeleteTime, deleteTime);
        }
        if (isDeleted!=null) {
            queryWrapper.eq(Corp::getIsDeleted, isDeleted);
        }
        return queryWrapper;
    }

}
